#pragma once
#include<iostream>
#include<assert.h>
#include<string.h>

using namespace std;

namespace str
{
	class string
	{
	public:
		typedef char* iterator;
		typedef const char* const_iterator;
		//-----------------------------------------------------------------------

		//string();
		string(const char* str = "");
		string(const string& str);
		~string();

		//-----------------------------------------------------------------------
		iterator begin();
		iterator end();
		iterator rbegin();
		iterator rend();

		const_iterator cbegin()const;
		const_iterator cend()const;

		//-----------------------------------------------------------------------
		void swap(string& s);
		const char* c_str();
		size_t size()const;
		void push_back(const char c);
		void reserve(size_t n);
		void append(const char* s);

		void insert(size_t pos, const char c);
		void insert(size_t pos, const char* s);
		void erase(size_t pos, size_t n = npos);

		size_t find(const char ch, size_t pos = 0 );
		size_t find( const char* str, size_t pos = 0);
		string substr(size_t pos = 0, size_t len = npos);
		//-----------------------------------------------------------------------
		char& operator[](size_t pos);
		const char&  operator[](size_t pos)const;

		//string& operator=(const string& str);
		string& operator=(string str);

		string& operator+=(const char ch);
		string& operator+=(const char* str);

		bool operator>(const string& s);
		bool operator>=(const string& s);
		bool operator<(const string& s);
		bool operator<=(const string& s);
		bool operator==(const string& s);
		bool operator!=(const string& s);
		//-----------------------------------------------------------------------


	private:
		iterator _str;
		size_t _size;
		size_t _capacity;
		const static size_t npos;
	};
	istream& operator>>(istream& in, string& s);
	ostream& operator<<(ostream& out, string& s);
}
